#include <stdio.h>

int main()
{
    int a = 0;
    int b = 0;
    while (scanf("%d %d", &a, &b) != EOF)
    {
        int arr[a][b];
        for (int i = 0; i < a; i++)
        {
            for (int j = 0; j < b; j++)
            {
                scanf("%d", &arr[i][j]);
            }
        }

        for (int i = 0; i < b; i++)
        {
            for (int j = 0; j < a; j++)
            {
                printf("%d ", arr[j][i]);
            }
            printf("\n");
        }
    }
    return 0;